{% extends "base.html" %}

{% block title %}View PDF{% endblock %}

{% block content %}
<div class="row mb-4">
    <div class="col">
        <h1>{{ file.original_filename }}</h1>
    </div>
    <div class="col-auto">
        <div class="btn-group">
            <a href="{{ url_for('main.download_file', file_id=file.id) }}" class="btn btn-success">Download</a>
            <a href="{{ url_for('main.index') }}" class="btn btn-secondary">Back to List</a>
        </div>
    </div>
</div>

<div class="row mb-3">
    <div class="col">
        <strong>Upload Date:</strong> {{ file.upload_date.strftime('%Y-%m-%d %H:%M:%S') }}<br>
        <strong>File Size:</strong> {{ (file.file_size / 1024)|round|int }} KB<br>
        <strong>Tags:</strong>
        {% if file.tags %}
        {% for tag in file.get_tags_list() %}
        <a href="{{ url_for('main.index', tag=tag) }}" class="badge bg-secondary text-decoration-none">{{ tag }}</a>
        {% endfor %}
        {% else %}
        <span class="text-muted">No tags</span>
        {% endif %}
    </div>
</div>

<div class="card">
    <div class="card-body p-0">
        <div id="pdf-viewer" style="height: 800px;">
            <iframe src="{{ url_for('main.download_file', file_id=file.id) }}" width="100%" height="100%" style="border: none;"></iframe>
        </div>
    </div>
</div>
{% endblock %}
